<?php

/*
 * This file is part of the FOSUserBundle package.
 *
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace INT\UserBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class RegistrationFormType extends AbstractType {

    private $class;

    /**
     * @param string $class The User class name
     */
    public function __construct($class) {
        $this->class = $class;
    }

    public function buildForm(FormBuilderInterface $builder, array $options) {
        $builder
                ->add('nom')
                ->add('prenom')
                ->add('cin')
                ->add('numero_carte_etudient')
                ->add('civilite', 'choice', array(
                     'choices' => array('Mr' => 'Mr.', 'Mme' => 'Mme.', 'Mlle' => 'Mlle.'),
                 ))
                ->add('date_naissance','date',array(
	            'widget' => 'single_text',
	            'format' => 'dd/MM/yyyy'
	        ))
                ->add('spec_ens')
                ->add('grad_ens')
                ->add('lieu_naissance')
                ->add('diplome_actuel')
                ->add('dernier_diplome')
                ->add('telephone')
                ->add('niveau')
                ->add('adresse')
                ->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle','invalid_message' => 'Please enter the same password twice',))
                ->add('email', 'email', array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'))
                ->add('plainPassword', 'repeated', array(
                    'type' => 'password',
                    'options' => array('translation_domain' => 'FOSUserBundle'),
                    'first_options' => array('label' => 'form.password'),
                    'second_options' => array('label' => 'form.password_confirmation'),
                    'invalid_message' => 'fos_user.password.mismatch',
                )) ;
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver) {
        $resolver->setDefaults(array(
            'data_class' => $this->class,
            'intention' => 'registration',
        ));
    }

    public function getName() {
        return 'int_user_registration';
    }

}
